<?php

namespace addons\kuerp\controller;

use addons\kuerp\model\OperationLog;

/**
 * 操作记录
 */
class Operation extends StaffApi {
	protected $noNeedLogin = [];
	protected $noNeedRight = [];


	//
	public function getList() {
		$relation_type = input('relation_type', '');//1客户 2联系人 3合同
		$relation_id   = input('relation_id', '');
		//操作记录
		$logs=OperationLog::where([
			'relation_type'  => $relation_type,
			'relation_id'    => $relation_id,
			'operation_type' => 1
		])->with(['staff'])->field('id,content,createtime,operation_id')->order('id desc')->select();
		if ($logs) {
			foreach ($logs as $key => $value) {
				$avatar = $value['staff']['img'] ? $value['staff']['img'] : '/assets/img/avatar.png';
            	$avatar = strpos($avatar, 'http') === false ? request()->domain() . $avatar : $avatar;
				$logs[$key]['staff']['img']=$avatar;
			}
		}
		$this->success('请求成功',$logs);
	}

}
